<?php
/**
 * Created by PhpStorm.
 * User: eugene
 * Date: 2018/4/23
 * Time: 17:18
 */

namespace App\Models\Merchant;


use App\Models\Member;
use Illuminate\Database\Eloquent\Model;

class GiftLog extends Model
{
    protected $table='merchant_logs';
    
    public function gift()
    {
        return $this->belongsTo(Gift::class,'merchant_gift_id','id')->withoutGlobalScopes();
    }
    
    public function member()
    {
        return $this->belongsTo(Member::class,'user_id','uid');
    }
    
    public function scopeUnsended($query)
    {
        return $query->where('is_sended',0);
    }
    
    public function scopeSended($query)
    {
        return $query->where('is_sended',1);
    }
    
    public function scopeUnused($query)
    {
        return $query->where('is_used',0);
    }
    
}